home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / DCLAP 4j / DBio / DSeqMail.cpp < prev    next >
Encoding:
Text File  |  1995-12-17  |  43.1 KB  |  1,677 lines  |  [TEXT/R*ch]

  1. // DSeqMail.cpp
  2. // d.g.gilbert
  3.  
  4.  
  5. #include <ncbi.h>
  6. #include <dgg.h>
  7. #include <DControl.h>
  8. #include <DPanel.h>
  9. #include <DTCP.h>
  10. #include <DSMTPclient.h>
  11. #include <DUtil.h>
  12. #include <DFile.h>
  13. #include <DSendMailDialog.h>
  14. #include <DSequence.h>
  15. #include <DSeqFile.h>
  16. #include <DApplication.h>
  17.  
  18. #include "DSeqMail.h"
  19.  
  20.  
  21. Local Nlm_FonT  gNoteFont = NULL;
  22. #define SETNOTEFONT()    if (!gNoteFont)    gNoteFont= Nlm_ParseFont("Times,9");
  23.  
  24. class DOptWindow : public DWindow
  25. {
  26. public:
  27.     DOptWindow(DView* superior, char* title) : 
  28.         DWindow(0, superior, DWindow::fixed, -5,  -5, -60, -30, title, kDontFreeOnClose) 
  29.             {}
  30.     void CloseAndFree() { this->Close(); }
  31. };
  32.  
  33.  
  34.  
  35. // class DNCBIBlast
  36.  
  37.  
  38. char* DNCBIBlast::kAddress = "blast@ncbi.nlm.nih.gov";
  39. char* DNCBIBlast::kTitle = "BLAST Search at NCBI";
  40. #ifdef OS_DOS
  41.   char* DNCBIBlast::kHelp     = "ncbi-bl.hel";     
  42. #else
  43.   char* DNCBIBlast::kHelp     = "ncbi-blast.help";     
  44. #endif                                                                     
  45.             
  46.                                                                                 
  47. DNCBIBlast::DNCBIBlast( long id, DTaskMaster* itsSuperior, DSequence* theSeq) :
  48.     DSendMailDialog(id, itsSuperior,    -5,  -5,  -50,  -20, kTitle),
  49.     fOptionWin(NULL)
  50. {
  51.     fSeq= (DSequence*) theSeq->Clone();
  52. }
  53.  
  54. DNCBIBlast::~DNCBIBlast()
  55. {
  56.     if (fOptionWin) delete fOptionWin; // !? is this handled by DView::DeleteSubviews() ???!!!
  57.     delete fSeq;
  58. }
  59.  
  60. char* DNCBIBlast::BuildMessage()
  61. {
  62.     enum blastMethod { blastp, tblastn, blastn, blastx } meth;
  63.     char        buf[512], name[128], *cp;
  64.     short         item;
  65.     DPopupList *pmeth, *plib;
  66.     char        *msg = NULL;
  67.     Boolean isamino= fBaseKind->GetValue() == 2;
  68.     
  69.             // want IOSTREAMS here !!!!!!!!!!!!!!!!!!!! not damn sprintf's
  70.     DTempFile* qfile = new DTempFile();
  71.  
  72.     pmeth= (isamino) ? fAmeth : fNmeth;
  73.     pmeth->GetSelectedItem(item,name,128);
  74.     cp= StrChr( name, ' '); if (cp) *cp= 0;
  75.     sprintf( buf, "PROGRAM %s\n", name); qfile->WriteLine(buf);
  76.     
  77.     if (StringCmp(name,"blastp") == 0) meth= blastp;
  78.     else if (StringCmp(name,"blastx") == 0) meth= blastx;
  79.     else if (StringCmp(name,"tblastn") == 0) meth= tblastn;
  80.     else meth= blastn;
  81.      
  82.     if (meth == blastp || meth == blastx) plib= fAlib;
  83.     else plib= fNlib;
  84.     plib->GetSelectedItem(item,name,128);
  85.     cp= StrChr( name, ' '); if (cp) *cp= 0;
  86.     sprintf( buf, "DATALIB %s\n", name);    qfile->WriteLine(buf);
  87.  
  88.     if (fOptionWin) {
  89.         fDesc->GetTitle(name,128); 
  90.         sprintf( buf, "DESCRIPTION %s\n", name); qfile->WriteLine(buf);
  91.         
  92.         fAlign->GetTitle(name,128); 
  93.         sprintf( buf, "ALIGNMENTS %s\n", name);  qfile->WriteLine(buf);
  94.     
  95.         fExpect->GetTitle(name,128); 
  96.         if (*name) { sprintf( buf, "EXPECT %s\n", name);    qfile->WriteLine(buf); }
  97.     
  98.         fCutoff->GetTitle(name,128); 
  99.         if (*name) { sprintf( buf, "CUTOFF %s\n", name);    qfile->WriteLine(buf); }
  100.     
  101.         if (meth != blastn) {
  102.             fMatrix->GetSelectedItem(item,name,128);
  103.             cp= StrChr( name, ' '); if (cp) *cp= 0;
  104.             sprintf( buf, "MATRIX %s\n", name);    qfile->WriteLine(buf);
  105.             }
  106.     
  107.         if (meth != blastn) {
  108.             fStrand->GetSelectedItem(item,name,128);
  109.             if (item > 1) {
  110.                 cp= StrChr( name, ' '); if (cp) *cp= 0;
  111.                 sprintf( buf, "STRAND %s\n", name);    qfile->WriteLine(buf);
  112.                 }
  113.             }
  114.     
  115.         fFilter->GetSelectedItem(item,name,128);
  116.         if (item > 1) {
  117.             cp= StrChr( name, ' '); if (cp) *cp= 0;
  118.             sprintf( buf, "FILTER %s\n", name);    qfile->WriteLine(buf);
  119.             }
  120.             
  121.         if (fHistogram->GetStatus() && meth != blastx) { 
  122.             sprintf( buf, "HISTOGRAM yes\n");    qfile->WriteLine(buf); 
  123.             }
  124.         }
  125.         
  126.     sprintf( buf, "BEGIN\n", name);    qfile->WriteLine(buf);
  127.     
  128.         //!! must use bases from fMsg text
  129.     msg= fMsg->GetText();
  130.     fSeq->SetBases( msg);
  131.     MemFree(msg);
  132.     fSeq->DoWrite( qfile, DSeqFile::kPearson); 
  133.         
  134.     ulong msgbytes;
  135.     msg= qfile->ReadIntoMemory( msgbytes);
  136.     delete qfile;
  137.  
  138.     return msg;
  139. }
  140.  
  141.  
  142.  
  143. Boolean DNCBIBlast::IsMyAction(DTaskMaster* action) 
  144. {    
  145.     switch(action->Id()) {
  146.  
  147.         case cProtMeth:
  148.             if (fAmeth->GetValue() == 1) {
  149.                 fNlib->Disable();
  150.                 fAlib->Enable();
  151.                 }
  152.             else {
  153.                 fAlib->Disable();
  154.                 fNlib->Enable();
  155.                 }
  156.             return true;
  157.  
  158.         case cNucMeth:
  159.             if (fNmeth->GetValue() == 2) {
  160.                 fNlib->Disable();
  161.                 fAlib->Enable();
  162.                 }
  163.             else {
  164.                 fAlib->Disable();
  165.                 fNlib->Enable();
  166.                 }
  167.             return true;
  168.             
  169.         case cBaseKind:
  170.             if (fBaseKind->GetValue() == 2) {
  171.                 fNmeth->Hide();
  172.                 fAmeth->Show();
  173.                 }
  174.             else {
  175.                 fAmeth->Hide();
  176.                 fNmeth->Show();
  177.                 }
  178.             return true;
  179.             
  180.         case cOptions:
  181.             if (!fOptionWin) Options(); // build window
  182.             if ( fOptionWin) fOptionWin->Open();
  183.             return true;
  184.             
  185.         case cHelpButton:
  186.             gApplication->OpenHelp(kHelp);
  187.             return true;            
  188.          
  189.         default:
  190.             return DSendMailDialog::IsMyAction(action);    
  191.         }
  192. }
  193.  
  194.  
  195.  
  196.  
  197. void DNCBIBlast::Options()
  198. {
  199.     fOptionWin= new DOptWindow(this,"Blast Options");
  200.     DView* super = fOptionWin;
  201.  
  202.             // this needs to be a subsidiary window...
  203.     //DCluster* clu= new DCluster(0,super,0,0,false,"Options");
  204.     //super= clu;
  205.     
  206.     (void) new DPrompt(0, super, "Max. descriptions of matching seqs");
  207.     super->NextSubviewToRight();
  208.     fDesc= new DEditText(0,super,"100",6);
  209.     super->NextSubviewBelowLeft();
  210.     
  211.     (void) new DPrompt(0, super, "Max. alignments of high scoring pairs");
  212.     super->NextSubviewToRight();
  213.     fAlign= new DEditText(0,super,"50",6);
  214.     super->NextSubviewBelowLeft();
  215.  
  216.     (void) new DPrompt(0, super, "Expectation cutoff (real number)");
  217.     super->NextSubviewToRight();
  218.     fExpect= new DEditText(0,super,NULL,6);
  219.     super->NextSubviewBelowLeft();
  220.  
  221.     (void) new DPrompt(0, super, "Cutoff score from expectation (integer)");
  222.     super->NextSubviewToRight();
  223.     fCutoff= new DEditText(0,super,NULL,6);
  224.     super->NextSubviewBelowLeft();
  225.  
  226.     fHistogram= new DCheckBox(0,super,"Show Histogram");
  227.     super->NextSubviewBelowLeft();
  228.     
  229.     (void) new DPrompt(0, super, "Subsitition matrix");
  230.     super->NextSubviewToRight();
  231.     fMatrix= new DPopupList( cMatrix, super);
  232.     fMatrix->AddItem("blosum62");
  233.     fMatrix->AddItem("pam40");
  234.     fMatrix->AddItem("pam120");
  235.     fMatrix->AddItem("pam250");
  236.     fMatrix->SetValue(1);
  237.     super->NextSubviewBelowLeft();
  238.     
  239.     (void) new DPrompt(0, super, "Strand");
  240.     super->NextSubviewToRight();
  241.     fStrand= new DPopupList( cStrand, super);
  242.     fStrand->AddItem("both");
  243.     fStrand->AddItem("top | plus | +");
  244.     fStrand->AddItem("bottom | minus | -");
  245.     fStrand->SetValue(1);
  246.     super->NextSubviewBelowLeft();
  247.     
  248.     (void) new DPrompt(0, super, "Filter junk");
  249.     super->NextSubviewToRight();
  250.     fFilter= new DPopupList( cFilter, super);
  251.     fFilter->AddItem(" no filtering");
  252.     fFilter->AddItem("SEG - mask out low compositional complexity");
  253.     fFilter->AddItem("XNU - mask out short-periodicity internal repeats");
  254.     fFilter->AddItem("SEG+XNU - filter SEG then XNU");
  255.     fFilter->AddItem("XNU+SEG - filter XNU then SEG");
  256.     fFilter->SetValue(1);
  257.     super->NextSubviewBelowLeft();
  258.  
  259. }
  260.  
  261.  
  262.  
  263. void DNCBIBlast::Open()
  264. {
  265.     DView* super = this;
  266.     DCluster* clu;
  267.  
  268.     char *shorthelp1= 
  269. "The BLAST algorithm is a heuristic for finding ungapped,"LINEEND
  270. "locally optimal sequence alignments.";
  271.     SETNOTEFONT();
  272.     (void) new DNotePanel(0,super,shorthelp1, 25*Nlm_stdCharWidth,0,gNoteFont);
  273.     
  274.     super->NextSubviewBelowLeft();
  275.  
  276.     DView *eto  = this->InstallTo(super, kAddress);
  277.     DView *efrom= this->InstallFrom(super);  // don't have to display this one
  278.     DView *esubj= NULL; 
  279.     DView *eccopy= NULL;
  280.  
  281.     clu= new DCluster(0,super,0,0,true,"");
  282.     super= clu;
  283.     
  284.     fBaseKind= new DCluster(cBaseKind,super,0,0,false,"Bases are");
  285.     super= fBaseKind;
  286.     (void) new DRadioButton(0,super,"Nucleic");
  287.     super->NextSubviewToRight();
  288.     (void) new DRadioButton(0,super,"Amino");
  289.     if (fSeq->IsAmino()) fBaseKind->SetValue(2); else fBaseKind->SetValue(1);
  290.     
  291.     super= clu;
  292.     
  293.     super->NextSubviewToRight();
  294.     fOptions= new DButton( cOptions, super, "Options");
  295.     fOptions->SetResize( DView::fixed, DView::moveinsuper);
  296.  
  297.     super->NextSubviewBelowLeft();
  298.  
  299.     (void) new DPrompt(0, super, "Search method");
  300.     super->NextSubviewBelowLeft();
  301.     
  302.     fAmeth= new DPopupList( cProtMeth, super);
  303.     fAmeth->AddItem("blastp - amino query vs. protein lib");
  304.     fAmeth->AddItem("tblastn - amino query vs. all frames of nucleic lib");    
  305.     fAmeth->SetValue(1);
  306.  
  307.     fNmeth= new DPopupList( cNucMeth, super);
  308.     fNmeth->AddItem("blastn - nucleic query vs. nucleic lib");
  309.     fNmeth->AddItem("blastx - nucleic in all frames vs. amino lib");    
  310.     fNmeth->SetValue(1);
  311.  
  312.     if (fSeq->IsAmino()) fNmeth->Hide(); else fAmeth->Hide();
  313.     super->NextSubviewBelowLeft();
  314.     
  315.     
  316.     (void) new DPrompt(0, super, "Nucleic library");
  317.     super->NextSubviewBelowLeft();
  318.     fNlib= new DPopupList( cNucLib, super);
  319.     fNlib->AddItem("nr - non-redundant nucleic lib, full & updates");
  320.     fNlib->AddItem("genbank - latest full GenBank");
  321.     fNlib->AddItem("gbupdate - updates to GenBank");
  322.     fNlib->AddItem("embl - latest full EMBL");
  323.     fNlib->AddItem("emblu - updates to EMBL");
  324.     fNlib->AddItem("pdb - from Brookhaven Protein Data Bank");
  325.     fNlib->AddItem("vector - vector subset of GenBank");
  326.     fNlib->AddItem("kabatnuc - from Kabat's sequences of immunological interest");
  327.     fNlib->AddItem("dbest - expressed sequence tags data");
  328.     fNlib->AddItem("epd - eukaroytic promotors");
  329.     fNlib->SetValue(1);
  330.     super->NextSubviewBelowLeft();
  331.  
  332.     (void) new DPrompt(0, super, "Protein library");
  333.     super->NextSubviewBelowLeft();
  334.     fAlib= new DPopupList( cProtLib, super);
  335.     fAlib->AddItem("nr - non-redundant protein lib, full & updates");
  336.     fAlib->AddItem("swissprot - latest full Swiss-Prot");
  337.     fAlib->AddItem("pir - latest full PIR");
  338.     fAlib->AddItem("spupdate - updates to swiss-prot");
  339.     fAlib->AddItem("genpept - GenPept, translated from full GenBank");
  340.     fAlib->AddItem("gpupdate - updates to GenPept");
  341.     fAlib->AddItem("pdb - from Brookhaven Protein Data Bank");
  342.     fAlib->AddItem("kabatpro - from Kabat's sequences of immunological interest");
  343.     fAlib->AddItem("tfd - transcription factors protein database");
  344.     fAlib->AddItem("palu - 6-frame translations of human Alu repeats");
  345.     fAlib->SetValue(1);
  346.     super->NextSubviewBelowLeft();
  347.  
  348.     super= this;
  349.     super->NextSubviewBelowLeft();
  350.  
  351.     (void) new DPrompt(0, super, "Your query sequence");
  352.     super->NextSubviewBelowLeft();
  353.     DView *emsg= this->InstallMessage(super, fSeq->Bases());
  354.     
  355.     SetDlogItems( eto, efrom, eccopy, esubj, emsg);
  356.     
  357.     AddOkayCancelButtons(cSEND,"Send");
  358.     
  359.     this->NextSubviewToRight();
  360.     DButton* hb= new DButton( cHelpButton, this, "Help");
  361.     hb->SetResize( DView::fixed, DView::moveinsuper);
  362.     
  363.     DWindow::Open();
  364. }
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371. // class DNCBIFetch
  372.  
  373.  
  374.   char* DNCBIFetch::kAddress = "retrieve@ncbi.nlm.nih.gov";
  375.   char* DNCBIFetch::kTitle = "Fetch from NCBI";
  376.  
  377. #ifdef OS_DOS
  378.   char* DNCBIFetch::kHelp     = "ncbi-ret.hel";     
  379. #else
  380.   char* DNCBIFetch::kHelp     = "ncbi-retrieve.help";     
  381. #endif                                            
  382.                          
  383.                                                                                 
  384. DNCBIFetch::DNCBIFetch( long id, DTaskMaster* itsSuperior) :
  385.     DSendMailDialog(id, itsSuperior,    -5,  -5,  -50,  -20, kTitle)
  386. {
  387. }
  388.  
  389.  
  390. char* DNCBIFetch::BuildMessage()
  391. {
  392.     char        buf[512], name[128], *cp;
  393.     short         item;
  394.     char        *msg = NULL;
  395.     
  396.             // want IOSTREAMS here !!!!!!!!!!!!!!!!!!!! not damn sprintf's
  397.     DTempFile* qfile = new DTempFile();
  398.  
  399.     fLib->GetSelectedItem(item,name,128);
  400.     cp= StrChr( name, ' '); if (cp) *cp= 0;
  401.     sprintf( buf, "DATALIB %s\n", name);    qfile->WriteLine(buf);
  402.  
  403.     fDocs->GetTitle(name,128); 
  404.     sprintf( buf, "MAXDOCS %s\n", name); qfile->WriteLine(buf);
  405.     
  406.     fLines->GetTitle(name,128); 
  407.     sprintf( buf, "MAXLINES %s\n", name);  qfile->WriteLine(buf);
  408.  
  409.     if (fTitles->GetStatus()) { 
  410.         sprintf( buf, "TITLES yes\n");    qfile->WriteLine(buf); 
  411.         }
  412.  
  413.     fStart->GetTitle(name,128); 
  414.     if (*name) { sprintf( buf, "STARTDOC %s\n", name);    qfile->WriteLine(buf); }
  415.         
  416.     sprintf( buf, "BEGIN\n", name);    qfile->WriteLine(buf);
  417.     
  418.     msg= fMsg->GetText();
  419.     qfile->WriteLine(msg);
  420.     MemFree(msg);
  421.     
  422.     ulong msgbytes;
  423.     msg= qfile->ReadIntoMemory( msgbytes);
  424.     delete qfile;
  425.  
  426.     return msg;
  427. }
  428.  
  429.  
  430.  
  431. Boolean DNCBIFetch::IsMyAction(DTaskMaster* action) 
  432. {    
  433.     switch(action->Id()) {
  434.             
  435.         case cHelpButton:
  436.             gApplication->OpenHelp(kHelp);
  437.             return true;            
  438.          
  439.         default:
  440.             return DSendMailDialog::IsMyAction(action);    
  441.         }
  442. }
  443.  
  444.  
  445.  
  446. void DNCBIFetch::Open()
  447. {
  448.     DView* super = this;
  449.  
  450.     char *shorthelp1= 
  451. "NCBI Retrieve server allows you to fetch database entries.";
  452.     SETNOTEFONT();
  453.     (void) new DNotePanel(0,super,shorthelp1, 25*Nlm_stdCharWidth, 0, gNoteFont);
  454.     super->NextSubviewBelowLeft();
  455.  
  456.     DView *eto  = this->InstallTo(super, kAddress);
  457.     DView *efrom= this->InstallFrom(super);  // don't have to display this one
  458.     DView *esubj= NULL; 
  459.     DView *eccopy= NULL;
  460.  
  461.     (void) new DPrompt(0, super, "Max. documents to send");
  462.     super->NextSubviewToRight();
  463.     fDocs= new DEditText(0,super,"20",6);
  464.     super->NextSubviewBelowLeft();
  465.  
  466.     (void) new DPrompt(0, super, "Max. lines to send");
  467.     super->NextSubviewToRight();
  468.     fLines= new DEditText(0,super,"1000",6);
  469.     super->NextSubviewBelowLeft();
  470.     
  471.     (void) new DPrompt(0, super, "Starting document number");
  472.     super->NextSubviewToRight();
  473.     fStart= new DEditText(0,super,"1",6);
  474.     super->NextSubviewBelowLeft();
  475.     
  476.     fTitles= new DCheckBox(0,super,"Display titles only");
  477.     super->NextSubviewBelowLeft();
  478.  
  479.     (void) new DPrompt(0, super, "Data library");
  480.     super->NextSubviewBelowLeft();
  481.     fLib= new DPopupList( cDataLib, super);
  482.     fLib->AddItem("genbank - latest full GenBank and updates");
  483.     fLib->AddItem("gbupdate - updates to GenBank");
  484.     fLib->AddItem("gbonly - latest full GenBank without updates");
  485.     fLib->AddItem("embl - latest full EMBL");
  486.     fLib->AddItem("emblupdate - updates to EMBL");
  487.     fLib->AddItem("swissprot - latest full Swiss-Prot");
  488.     fLib->AddItem("swissprotupdate - updates to swiss-prot");
  489.     fLib->AddItem("pir - latest full PIR");
  490.     //fLib->AddItem("pdb - from Brookhaven Protein Data Bank");
  491.     fLib->AddItem("vector - vector subset of GenBank");
  492.     fLib->AddItem("vecbase - Vecbase, 1987 version");
  493.     fLib->AddItem("genpept - GenPept, translated from full GenBank");
  494.     fLib->AddItem("gpupdate - updates to GenPept");
  495.     fLib->AddItem("kabatnuc - dna of Kabat's immunological seqs");
  496.     fLib->AddItem("kabatpro - protein of Kabat's immunological seqs");
  497.     fLib->AddItem("epd - eukaroytic promotors");
  498.     fLib->AddItem("tfd - transcription factors database");
  499.     fLib->SetValue(1);
  500.     super->NextSubviewBelowLeft();
  501.  
  502.     super= this;
  503.     super->NextSubviewBelowLeft();
  504.  
  505.     char *shorthelp= 
  506. "Your query can contain several lines with locus names, accession numbers, authors'"LINEEND
  507. "names, and/or text words. The logical operators AND, OR, and NOT are supported.";
  508.  
  509.     SETNOTEFONT();
  510.     (void) new DNotePanel(0,super,shorthelp, 25*Nlm_stdCharWidth,0,gNoteFont);
  511.     super->NextSubviewBelowLeft();
  512.  
  513.     (void) new DPrompt(0, super, "Your query:");
  514.     super->NextSubviewBelowLeft();
  515.     DView *emsg= this->InstallMessage(super);
  516.     
  517.     SetDlogItems( eto, efrom, eccopy, esubj, emsg);
  518.     
  519.     AddOkayCancelButtons(cSEND,"Send");
  520.     this->NextSubviewToRight();
  521.     DButton* hb= new DButton( cHelpButton, this, "Help");
  522.     hb->SetResize( DView::fixed, DView::moveinsuper);
  523.     
  524.     DWindow::Open();
  525. }
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532. // class DEMBLBlitz
  533.  
  534.  
  535. //char* DEMBLBlitz::kAddress = "seqpup@bio.indiana.edu";
  536. char* DEMBLBlitz::kAddress = "BLITZ@EMBL-Heidelberg.DE";
  537. char* DEMBLBlitz::kTitle = "Blitz Search at EMBL";
  538.  
  539. #ifdef OS_DOS
  540. char* DEMBLBlitz::kHelp     = "embl-bli.hel";     
  541. #else
  542. char* DEMBLBlitz::kHelp     = "embl-blitz.help";     
  543. #endif                                                                     
  544.             
  545.                                                                                 
  546. DEMBLBlitz::DEMBLBlitz( long id, DTaskMaster* itsSuperior, DSequence* theSeq) :
  547.     DSendMailDialog(id, itsSuperior,    -5,  -5,  -50,  -20, kTitle)
  548. {
  549.     fSeq= (DSequence*) theSeq->Clone();
  550. }
  551.  
  552. DEMBLBlitz::~DEMBLBlitz()
  553. {
  554.     delete fSeq;
  555. }
  556.  
  557. char* DEMBLBlitz::BuildMessage()
  558. {
  559.     char        buf[512], name[128];
  560.     char        *msg = NULL;
  561.     Boolean isamino= fBaseKind->GetValue() == 2;
  562.     
  563.             // want IOSTREAMS here !!!!!!!!!!!!!!!!!!!! not damn sprintf's
  564.     DTempFile* qfile = new DTempFile();
  565.  
  566.     fTitle->GetTitle(name,128); 
  567.     if (*name) { sprintf( buf, "TITLE %s\n", name); qfile->WriteLine(buf); }
  568.     
  569.     fAlign->GetTitle(name,128); 
  570.     if (*name) { sprintf( buf, "ALIGN %s\n", name);  qfile->WriteLine(buf); }
  571.  
  572.     fScores->GetTitle(name,128); 
  573.     if (*name) { sprintf( buf, "NAME %s\n", name);    qfile->WriteLine(buf); }
  574.  
  575.     fIndel->GetTitle(name,128); 
  576.     if (*name) { sprintf( buf, "INDEL %s\n", name);    qfile->WriteLine(buf); }
  577.  
  578.     if (isamino) {
  579.         fPam->GetTitle(name,128); 
  580.         sprintf( buf, "PAM %s\n", name);    qfile->WriteLine(buf);
  581.         }
  582.         
  583.     sprintf( buf, "SEQ\n", name);    qfile->WriteLine(buf);
  584.     
  585.         //!! must use bases from fMsg text
  586.     msg= fMsg->GetText();
  587.     fSeq->SetBases( msg);
  588.     MemFree(msg);
  589.     fSeq->DoWrite( qfile, DSeqFile::kPlain); 
  590.         
  591.     sprintf( buf, "END\n");    qfile->WriteLine(buf);
  592.     
  593.     ulong msgbytes;
  594.     msg= qfile->ReadIntoMemory( msgbytes);
  595.     delete qfile;
  596.  
  597.     return msg;
  598. }
  599.  
  600.  
  601.  
  602. Boolean DEMBLBlitz::IsMyAction(DTaskMaster* action) 
  603. {    
  604.     switch(action->Id()) {
  605.  
  606.         case cBaseKind:
  607.             if (fBaseKind->GetValue() == 2) {
  608.                 fPam->Enable();
  609.                 }
  610.             else {
  611.                 fPam->Disable();
  612.                 }
  613.             return true;
  614.             
  615.         case cHelpButton:
  616.             gApplication->OpenHelp(kHelp);
  617.             return true;            
  618.          
  619.         default:
  620.             return DSendMailDialog::IsMyAction(action);    
  621.         }
  622. }
  623.  
  624.  
  625.  
  626. void DEMBLBlitz::Open()
  627. {
  628.     DView* super = this;
  629.  
  630.     char *shorthelp1= 
  631. "MPsrch allows you to perform sensitive and fast comparisons of your protein sequences against"LINEEND
  632. "the Swiss-Prot database using the Smith and Waterman best local similarity algorithm.";
  633.     SETNOTEFONT();
  634.     (void) new DNotePanel(0,super,shorthelp1, 25*Nlm_stdCharWidth,0,gNoteFont);
  635.     super->NextSubviewBelowLeft();
  636.  
  637.     DView *eto  = this->InstallTo(super, kAddress);
  638.     DView *efrom= this->InstallFrom(super);  // don't have to display this one
  639.     DView *esubj= NULL; 
  640.     DView *eccopy= NULL;
  641.  
  642.     fBaseKind= new DCluster(cBaseKind,super,0,0,false,"Bases are");
  643.     super= fBaseKind;
  644.     (void) new DRadioButton(0,super,"Nucleic");
  645.     super->NextSubviewToRight();
  646.     (void) new DRadioButton(0,super,"Amino");
  647.     if (fSeq->IsAmino()) fBaseKind->SetValue(2); else fBaseKind->SetValue(1);
  648.     
  649.     super= this;
  650.     super->NextSubviewBelowLeft();
  651.  
  652.     (void) new DPrompt(0, super, "Max. scores to report");
  653.     super->NextSubviewToRight();
  654.     fScores= new DEditText(0,super,"50",6);
  655.     super->NextSubviewBelowLeft();
  656.  
  657.     (void) new DPrompt(0, super, "Max. best alignments to report");
  658.     super->NextSubviewToRight();
  659.     fAlign= new DEditText(0,super,"50",6);
  660.     super->NextSubviewBelowLeft();
  661.  
  662.     (void) new DPrompt(0, super, "Indel penalty (option)");
  663.     super->NextSubviewToRight();
  664.     fIndel= new DEditText(0,super,NULL,6);
  665.     super->NextSubviewBelowLeft();
  666.  
  667.     (void) new DPrompt(0, super, "PAM value from 1..500 (protein option)");
  668.     super->NextSubviewToRight();
  669.     fPam= new DEditText(0,super,NULL,6);
  670.     if (!fSeq->IsAmino()) fPam->Disable();
  671.     super->NextSubviewBelowLeft();
  672.  
  673.     (void) new DPrompt(0, super, "Title of this search");
  674.     super->NextSubviewBelowLeft();
  675.     char  title[80];
  676.     StrCpy(title, "Blitz of ");
  677.     StrNCat(title, fSeq->Name(), 30);
  678.     fTitle= new DEditText(0,super,title,30);
  679.     super->NextSubviewBelowLeft();
  680.  
  681.     (void) new DPrompt(0, super, "Your query sequence:");
  682.     super->NextSubviewBelowLeft();
  683.     DView *emsg= this->InstallMessage(super, fSeq->Bases());
  684.     
  685.     SetDlogItems( eto, efrom, eccopy, esubj, emsg);
  686.     
  687.     AddOkayCancelButtons(cSEND,"Send");
  688.     this->NextSubviewToRight();
  689.     DButton* hb= new DButton( cHelpButton, this, "Help");
  690.     hb->SetResize( DView::fixed, DView::moveinsuper);
  691.     
  692.     DWindow::Open();
  693. }
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701. // class DEMBLFasta
  702.  
  703.  
  704. char* DEMBLFasta::kAddress = "FASTA@EMBL-Heidelberg.DE";
  705. char* DEMBLFasta::kTitle = "FastA Search at EMBL";
  706. #ifdef OS_DOS
  707. char* DEMBLFasta::kHelp     = "embl-fas.hel";     
  708. #else
  709. char* DEMBLFasta::kHelp     = "embl-fasta.help";     
  710. #endif                                                                     
  711.             
  712.                                                                                 
  713. DEMBLFasta::DEMBLFasta( long id, DTaskMaster* itsSuperior, DSequence* theSeq) :
  714.     DSendMailDialog(id, itsSuperior,    -5,  -5,  -50,  -20, kTitle)
  715. {
  716.     fSeq= (DSequence*) theSeq->Clone();
  717. }
  718.  
  719. DEMBLFasta::~DEMBLFasta()
  720. {
  721.     delete fSeq;
  722. }
  723.  
  724. char* DEMBLFasta::BuildMessage()
  725. {
  726.     char        buf[512], name[128], *cp;
  727.     short         item;
  728.     char        *msg = NULL;
  729.     Boolean isamino= fBaseKind->GetValue() == 2;
  730.     
  731.             // want IOSTREAMS here !!!!!!!!!!!!!!!!!!!! not damn sprintf's
  732.     DTempFile* qfile = new DTempFile();
  733.  
  734.     fTitle->GetTitle(name,128); 
  735.     if (*name) { sprintf( buf, "TITLE %s\n", name); qfile->WriteLine(buf); }
  736.     
  737.     fScores->GetTitle(name,128); 
  738.     if (*name) { sprintf( buf, "LIST %s\n", name);    qfile->WriteLine(buf); }
  739.  
  740.     fAlign->GetTitle(name,128); 
  741.     if (*name) { sprintf( buf, "ALIGN %s\n", name);  qfile->WriteLine(buf); }
  742.  
  743.     fWord->GetTitle(name,128); 
  744.     if (*name) { sprintf( buf, "WORD %s\n", name);    qfile->WriteLine(buf); }
  745.  
  746.     fLib->GetSelectedItem(item,name,128);
  747.     cp= StrChr( name, ' '); if (cp) *cp= 0;
  748.     if (*name) { sprintf( buf, "LIB %s\n", name);    qfile->WriteLine(buf); }
  749.      
  750.     if (!fBothStrands->GetStatus()) { 
  751.         sprintf( buf, "ONE\n");    qfile->WriteLine(buf); 
  752.         }
  753.     
  754.     if (isamino && fSeq->LengthF()<50) {
  755.         sprintf( buf, "PROT\n");    qfile->WriteLine(buf);
  756.         }
  757.         
  758.     sprintf( buf, "SEQ %s\n", name);    qfile->WriteLine(buf);
  759.     
  760.         //!! must use bases from fMsg text
  761.     msg= fMsg->GetText();
  762.     fSeq->SetBases( msg);
  763.     MemFree(msg);
  764.     fSeq->DoWrite( qfile, DSeqFile::kPlain); 
  765.         
  766.     sprintf( buf, "END\n");    qfile->WriteLine(buf);
  767.     
  768.     ulong msgbytes;
  769.     msg= qfile->ReadIntoMemory( msgbytes);
  770.     delete qfile;
  771.  
  772.     return msg;
  773. }
  774.  
  775.  
  776.  
  777. Boolean DEMBLFasta::IsMyAction(DTaskMaster* action) 
  778. {    
  779.     switch(action->Id()) {
  780.  
  781.         case cBaseKind:
  782.             if (fBaseKind->GetValue() == 2) {
  783.                 //fPam->Enable();
  784.                 }
  785.             else {
  786.                 //fPam->Disable();
  787.                 }
  788.             return true;
  789.             
  790.         case cHelpButton:
  791.             gApplication->OpenHelp(kHelp);
  792.             return true;            
  793.          
  794.         default:
  795.             return DSendMailDialog::IsMyAction(action);    
  796.         }
  797. }
  798.  
  799.  
  800.  
  801. void DEMBLFasta::Open()
  802. {
  803.     DView* super = this;
  804.  
  805.     char *shorthelp1= 
  806. "This is based on the FASTA program developed by Pearson and Lipman.  It allows you to perform"LINEEND
  807. "fast and sensitive comparisons of your nucleic acid or protein sequences against various databases.";
  808.     SETNOTEFONT();
  809.     (void) new DNotePanel(0,super,shorthelp1, 25*Nlm_stdCharWidth,0,gNoteFont);
  810.     super->NextSubviewBelowLeft();
  811.  
  812.     DView *eto  = this->InstallTo(super, kAddress);
  813.     DView *efrom= this->InstallFrom(super);  // don't have to display this one
  814.     DView *esubj= NULL; 
  815.     DView *eccopy= NULL;
  816.  
  817.  
  818.     (void) new DPrompt(0, super, "Data library:");
  819.     super->NextSubviewBelowLeft();
  820.     fLib= new DPopupList( cDataLib, super);
  821.     fLib->AddItem("EMALL - latest full EMBL & updates");
  822.     fLib->AddItem("EMNEW - updates to EMBL");
  823.     fLib->AddItem(" --- ");
  824.     fLib->AddItem("EFUN - EMBL fungi division only");
  825.     fLib->AddItem("EINV - EMBL invertebrates division only");
  826.     fLib->AddItem("EMAM - EMBL mammals division only");
  827.     fLib->AddItem("EORG - EMBL organelles division only");
  828.     fLib->AddItem("EPHG - EMBL phages division only");
  829.     fLib->AddItem("EPLN - EMBL plants division only");
  830.     fLib->AddItem("EPRI - EMBL primates division only");
  831.     fLib->AddItem("EPRO - EMBL prokaryotes division only");
  832.     fLib->AddItem("EROD - EMBL rodents division only");
  833.     fLib->AddItem("ESYN - EMBL synthetic division only");
  834.     fLib->AddItem("EUNA - EMBL unannotated division only");
  835.     fLib->AddItem("EVRL - EMBL viruses division only");
  836.     fLib->AddItem("EVRT - EMBL vertebrates division only");
  837.     fLib->AddItem(" --- ");
  838.     fLib->AddItem("GBALL - latest full GenBank & updates");
  839.     fLib->AddItem("GBNEW - updates to GenBank");
  840.     fLib->AddItem("GBONLY - latest full GenBank");
  841.     fLib->AddItem("GENEMBL - latest full Genbank & EMBL");
  842.     fLib->AddItem("GENEW - updates to GenBank & EMBL");
  843.     fLib->AddItem(" --- ");
  844.     fLib->AddItem("SWALL - latest full swiss-prot & updates");
  845.     fLib->AddItem("SWNEW - updates to swiss-prot");
  846.     fLib->AddItem("SW - latest full swiss-prot");
  847.     fLib->AddItem("NBRF - latest full NBRF|PIR");
  848.     fLib->AddItem("PIRONLY - entries in PIR, but not swiss-prot");
  849.     fLib->AddItem("SWISSPIRALL - latest full swiss-prot & PIR");
  850.     fLib->AddItem("BROOKHAVEN - from Brookhaven protein data bank");
  851.     fLib->AddItem("NRL - from Brookhaven PDB, NBRF version");
  852.     fLib->SetValue(1);
  853.     super->NextSubviewBelowLeft();
  854.  
  855.  
  856.     (void) new DPrompt(0, super, "Max. scores to report");
  857.     super->NextSubviewToRight();
  858.     fScores= new DEditText(0,super,"50",6);
  859.     super->NextSubviewBelowLeft();
  860.  
  861.     (void) new DPrompt(0, super, "Max. best alignments to report");
  862.     super->NextSubviewToRight();
  863.     fAlign= new DEditText(0,super,"10",6);
  864.     super->NextSubviewBelowLeft();
  865.  
  866.     (void) new DPrompt(0, super, "Word size (optional)");
  867.     super->NextSubviewToRight();
  868.     fWord= new DEditText(0,super,NULL,6);
  869.     super->NextSubviewBelowLeft();
  870.  
  871.     fBaseKind= new DCluster(cBaseKind,super,0,0,false,"Bases are");
  872.     super= fBaseKind;
  873.     (void) new DRadioButton(0,super,"Nucleic");
  874.     super->NextSubviewToRight();
  875.     (void) new DRadioButton(0,super,"Amino");
  876.     if (fSeq->IsAmino()) fBaseKind->SetValue(2); else fBaseKind->SetValue(1);
  877.     
  878.     super= this;
  879.     super->NextSubviewToRight();
  880.     fBothStrands= new DCheckBox(0,super,"Search both strands");
  881.     fBothStrands->SetStatus(true);
  882.     super->NextSubviewBelowLeft();
  883.  
  884.     (void) new DPrompt(0, super, "Title of this search");
  885.     super->NextSubviewBelowLeft();
  886.     char  title[80];
  887.     StrCpy(title, "FastA of ");
  888.     StrNCat(title, fSeq->Name(), 30);
  889.     fTitle= new DEditText(0,super,title,30);
  890.     super->NextSubviewBelowLeft();
  891.  
  892.     (void) new DPrompt(0, super, "Your query sequence:");
  893.     super->NextSubviewBelowLeft();
  894.     DView *emsg= this->InstallMessage(super, fSeq->Bases());
  895.     
  896.     SetDlogItems( eto, efrom, eccopy, esubj, emsg);
  897.     
  898.     AddOkayCancelButtons(cSEND,"Send");
  899.     this->NextSubviewToRight();
  900.     DButton* hb= new DButton( cHelpButton, this, "Help");
  901.     hb->SetResize( DView::fixed, DView::moveinsuper);
  902.     
  903.     DWindow::Open();
  904. }
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914. // class DEMBLQuicks
  915.  
  916.  
  917. char* DEMBLQuicks::kAddress = "QUICK@EMBL-Heidelberg.DE";
  918. char* DEMBLQuicks::kTitle = "QuickSearch at EMBL";
  919. #ifdef OS_DOS
  920. char* DEMBLQuicks::kHelp     = "emblquic.hel";     
  921. #else
  922. char* DEMBLQuicks::kHelp     = "embl-quicksearch.help";     
  923. #endif                                                                     
  924.             
  925.                                                                                 
  926. DEMBLQuicks::DEMBLQuicks( long id, DTaskMaster* itsSuperior, DSequence* theSeq) :
  927.     DSendMailDialog(id, itsSuperior,    -5,  -5,  -50,  -20, kTitle),
  928.     fSeq(NULL)
  929. {
  930.     if (theSeq->IsAmino()) {
  931.             Message(MSG_OK,"This method not available for Amino sequences.");
  932.             delete this;
  933.             return;
  934.             }
  935.     fSeq= (DSequence*) theSeq->Clone();
  936. }
  937.  
  938. DEMBLQuicks::~DEMBLQuicks()
  939. {
  940.     if (fSeq) delete fSeq;
  941. }
  942.  
  943. char* DEMBLQuicks::BuildMessage()
  944. {
  945.     char        buf[512], name[128], *cp;
  946.     short         item;
  947.     char        *msg = NULL;
  948.     
  949.             // want IOSTREAMS here !!!!!!!!!!!!!!!!!!!! not damn sprintf's
  950.     DTempFile* qfile = new DTempFile();
  951.  
  952.     fTitle->GetTitle(name,128); 
  953.     if (*name) { sprintf( buf, "TITLE %s\n", name); qfile->WriteLine(buf); }
  954.     
  955.     fLib->GetSelectedItem(item,name,128);
  956.     cp= StrChr( name, ' '); if (cp) *cp= 0;
  957.     if (*name) { sprintf( buf, "LIB %s\n", name);    qfile->WriteLine(buf); }
  958.      
  959.     fStringency->GetTitle(name,128); 
  960.     if (*name) { sprintf( buf, "STRINGENCY %s\n", name);  qfile->WriteLine(buf); }
  961.  
  962.     fWindow->GetTitle(name,128); 
  963.     if (*name) { sprintf( buf, "WINDOW %s\n", name);    qfile->WriteLine(buf); }
  964.  
  965.     if (fPerfect->GetStatus()) { 
  966.         sprintf( buf, "PERFECT\n");    qfile->WriteLine(buf); 
  967.         }
  968.     else {
  969.         fMatch->GetTitle(name,128); 
  970.         if (*name) { sprintf( buf, "MATCH %s\n", name);    qfile->WriteLine(buf); }
  971.         }
  972.  
  973.     fBest->GetSelectedItem(item,name,128);
  974.     if (item == 2) { sprintf( buf, "BEST\n");    qfile->WriteLine(buf); }
  975.  
  976.     if (!fBothStrands->GetStatus()) { 
  977.         sprintf( buf, "ONE\n");    qfile->WriteLine(buf); 
  978.         }
  979.         
  980.     sprintf( buf, "SEQ\n", name);    qfile->WriteLine(buf);
  981.     
  982.         //!! must use bases from fMsg text
  983.     msg= fMsg->GetText();
  984.     fSeq->SetBases( msg);
  985.     MemFree(msg);
  986.     fSeq->DoWrite( qfile, DSeqFile::kPlain); 
  987.         
  988.     sprintf( buf, "END\n");    qfile->WriteLine(buf);
  989.     
  990.     ulong msgbytes;
  991.     msg= qfile->ReadIntoMemory( msgbytes);
  992.     delete qfile;
  993.  
  994.     return msg;
  995. }
  996.  
  997.  
  998.  
  999. Boolean DEMBLQuicks::IsMyAction(DTaskMaster* action) 
  1000. {    
  1001.     switch(action->Id()) {
  1002.  
  1003.         case cHelpButton:
  1004.             gApplication->OpenHelp(kHelp);
  1005.             return true;            
  1006.          
  1007.         default:
  1008.             return DSendMailDialog::IsMyAction(action);    
  1009.         }
  1010. }
  1011.  
  1012.  
  1013.  
  1014. void DEMBLQuicks::Open()
  1015. {
  1016.     DView* super = this;
  1017.  
  1018.     char *shorthelp1= 
  1019. "This is based on the QUICKSEARCH and QUICKSHOW programs developed by John Devereux"LINEEND
  1020. "as implemented in the GCG package.  It allows you to perform very rapid comparisons"LINEEND
  1021. "of your nucleic acid sequences against the EMBL and GenBank databases including the"LINEEND
  1022. "most recent entries.";
  1023.     SETNOTEFONT();
  1024.     (void) new DNotePanel(0,super,shorthelp1, 25*Nlm_stdCharWidth,0,gNoteFont);
  1025.     super->NextSubviewBelowLeft();
  1026.  
  1027.     DView *eto  = this->InstallTo(super, kAddress);
  1028.     DView *efrom= this->InstallFrom(super);  // don't have to display this one
  1029.     DView *esubj= NULL; 
  1030.     DView *eccopy= NULL;
  1031.  
  1032.     (void) new DPrompt(0, super, "Data library:");
  1033.     super->NextSubviewBelowLeft();
  1034.     fLib= new DPopupList( 0, super);
  1035.     fLib->AddItem("ALL - all EMBL and GenBank entries");
  1036.     fLib->AddItem("GENEW - updates to GenBank & EMBL");
  1037.     fLib->SetValue(1);
  1038.     super->NextSubviewBelowLeft();
  1039.  
  1040.     (void) new DPrompt(0, super, "Percent identity for match");
  1041.     super->NextSubviewToRight();
  1042.     fMatch= new DEditText(0,super,"90",6);
  1043.     super->NextSubviewBelowLeft();
  1044.  
  1045.     fPerfect= new DCheckBox(0,super,"Perfect matches only");
  1046.     super->NextSubviewToRight();
  1047.     fBothStrands= new DCheckBox(0,super,"Search both strands");
  1048.     fBothStrands->SetStatus(true);
  1049.     super->NextSubviewBelowLeft();
  1050.  
  1051.     (void) new DPrompt(0, super, "Window (option)");
  1052.     super->NextSubviewToRight();
  1053.     fWindow= new DEditText(0,super,NULL,6);
  1054.     super->NextSubviewBelowLeft();
  1055.  
  1056.     (void) new DPrompt(0, super, "Stringency (option)");
  1057.     super->NextSubviewToRight();
  1058.     fStringency= new DEditText(0,super,NULL,6);
  1059.     super->NextSubviewBelowLeft();
  1060.  
  1061.     (void) new DPrompt(0, super, "Aligment method");
  1062.     super->NextSubviewToRight();
  1063.     fBest= new DPopupList( 0, super);
  1064.     fBest->AddItem("Needleman-Wunsch");
  1065.     fBest->AddItem("Local-homology");
  1066.     fBest->SetValue(1);
  1067.     super->NextSubviewBelowLeft();
  1068.  
  1069.     (void) new DPrompt(0, super, "Title of this search");
  1070.     super->NextSubviewBelowLeft();
  1071.     char  title[80];
  1072.     StrCpy(title, "Quicksearch of ");
  1073.     StrNCat(title, fSeq->Name(), 30);
  1074.     fTitle= new DEditText(0,super,title,30);
  1075.     super->NextSubviewBelowLeft();
  1076.  
  1077.     (void) new DPrompt(0, super, "Your query sequence:");
  1078.     super->NextSubviewBelowLeft();
  1079.     DView *emsg= this->InstallMessage(super, fSeq->Bases());
  1080.     
  1081.     SetDlogItems( eto, efrom, eccopy, esubj, emsg);
  1082.     
  1083.     AddOkayCancelButtons(cSEND,"Send");
  1084.     this->NextSubviewToRight();
  1085.     DButton* hb= new DButton( cHelpButton, this, "Help");
  1086.     hb->SetResize( DView::fixed, DView::moveinsuper);
  1087.     
  1088.     DWindow::Open();
  1089. }
  1090.  
  1091.  
  1092.  
  1093.  
  1094. // class DEMBLFetch
  1095.  
  1096. char* DEMBLFetch::kAddress = "NETSERV@EMBL-Heidelberg.DE";
  1097. char* DEMBLFetch::kTitle = "Fetch from EMBL";
  1098. #ifdef OS_DOS
  1099. char* DEMBLFetch::kHelp     = "embl-fet.hel";     
  1100. #else
  1101. char* DEMBLFetch::kHelp     = "embl-fetch.help";     
  1102. #endif                                            
  1103.                          
  1104.                                                                                 
  1105. DEMBLFetch::DEMBLFetch( long id, DTaskMaster* itsSuperior) :
  1106.     DSendMailDialog(id, itsSuperior,    -5,  -5,  -50,  -20, kTitle)
  1107. {
  1108. }
  1109.  
  1110. char* DEMBLFetch::BuildMessage()
  1111. {
  1112.     return fMsg->GetText();
  1113. }
  1114.  
  1115. Boolean DEMBLFetch::IsMyAction(DTaskMaster* action) 
  1116. {    
  1117.     switch(action->Id()) {
  1118.             
  1119.         case cHelpButton:
  1120.             gApplication->OpenHelp(kHelp);
  1121.             return true;            
  1122.          
  1123.         default:
  1124.             return DSendMailDialog::IsMyAction(action);    
  1125.         }
  1126. }
  1127.  
  1128.  
  1129. void DEMBLFetch::Open()
  1130. {
  1131.     DView* super = this;
  1132.  
  1133.     DView *eto  = this->InstallTo(super, kAddress);
  1134.     DView *efrom= this->InstallFrom(super);  // don't have to display this one
  1135.     DView *esubj= NULL; 
  1136.     DView *eccopy= NULL;
  1137.  
  1138.     char *shorthelp1= 
  1139. "Send one command per line. The general syntax is 'GET database:accnumber' where database is"LINEEND
  1140. "either NUC (EMBL or GenBank) or PROT (Swiss-Prot), eg. 'GET NUC:J00179'"LINEEND
  1141. "Include the command HELP to get introductory information.";
  1142.  
  1143.     SETNOTEFONT();
  1144.     (void) new DNotePanel(0,super,shorthelp1, 25*Nlm_stdCharWidth,0,gNoteFont);
  1145.     super->NextSubviewBelowLeft();
  1146.  
  1147.     (void) new DPrompt(0, super, "Your query:");
  1148.     super->NextSubviewBelowLeft();
  1149.     DView *emsg= this->InstallMessage(super);
  1150.     
  1151.     SetDlogItems( eto, efrom, eccopy, esubj, emsg);
  1152.     
  1153.     AddOkayCancelButtons(cSEND,"Send");
  1154.     this->NextSubviewToRight();
  1155.     DButton* hb= new DButton( cHelpButton, this, "Help");
  1156.     hb->SetResize( DView::fixed, DView::moveinsuper);
  1157.     
  1158.     DWindow::Open();
  1159. }
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166. // class DFHCRCfetch
  1167.  
  1168. char* DFHCRCfetch::kAddress = "blocks@howard.fhcrc.org";
  1169. char* DFHCRCfetch::kTitle = "Fetch from FHCRC BLOCKS";
  1170. #ifdef OS_DOS
  1171. char* DFHCRCfetch::kHelp     = "fhcrc-bl.hel";     
  1172. #else
  1173. char* DFHCRCfetch::kHelp     = "fhcrc-blocks.help";     
  1174. #endif                                            
  1175.      
  1176.                                                                                 
  1177. DFHCRCfetch::DFHCRCfetch( long id, DTaskMaster* itsSuperior) :
  1178.     DSendMailDialog(id, itsSuperior,    -5,  -5,  -50,  -20, kTitle)
  1179. {
  1180. }
  1181.  
  1182. char* DFHCRCfetch::BuildMessage()
  1183. {
  1184.     return "";  // sendmail requires nonNULL msg string
  1185. }
  1186.  
  1187. Boolean DFHCRCfetch::IsMyAction(DTaskMaster* action) 
  1188. {    
  1189.     switch(action->Id()) {
  1190.             
  1191.         case cHelpButton:
  1192.             gApplication->OpenHelp(kHelp);
  1193.             return true;            
  1194.          
  1195.         default:
  1196.             {
  1197.             char sub[128];
  1198.             fSubj->GetTitle(sub, 80);
  1199.             if (StrNICmp(sub,"GET ",4) != 0) {
  1200.                 char newsub[128];
  1201.                 StrCpy(newsub, "GET ");
  1202.                 StrCat(newsub, sub);
  1203.                 fSubj->SetTitle(newsub);
  1204.                 }
  1205.             return DSendMailDialog::IsMyAction(action);    
  1206.             }
  1207.         }
  1208. }
  1209.  
  1210. DView* DFHCRCfetch::InstallSubject(DView* super, char* subjStr)
  1211. {
  1212.     DPrompt* pr= new DPrompt(0, super, "Blocks to get:", 0, 0, Nlm_programFont);
  1213.     super->NextSubviewToRight();
  1214.  
  1215.     DDialogText* esubj= new DEditText(cSubj, super, subjStr, 20);
  1216.     this->SetEditText(esubj);
  1217.     super->NextSubviewBelowLeft();
  1218.     return esubj;
  1219. }
  1220.  
  1221.  
  1222. void DFHCRCfetch::Open()
  1223. {
  1224.     DView* super = this;
  1225.  
  1226.     DView *eto  = this->InstallTo(super, kAddress);
  1227.     DView *efrom= this->InstallFrom(super);  // don't have to display this one
  1228.  
  1229.     char *shorthelp1=
  1230. "Specify one BLOCKS number to get per message, eg. 'GET BL00044'";
  1231.     SETNOTEFONT();
  1232.     (void) new DNotePanel(0,super,shorthelp1, 20*Nlm_stdCharWidth,0,gNoteFont);
  1233.     super->NextSubviewBelowLeft();
  1234.  
  1235.     DView *esubj= this->InstallSubject(super, "GET "); 
  1236.     DView *eccopy= NULL;
  1237.  
  1238.     //(void) new DPrompt(0, super, "Your query:");
  1239.     //super->NextSubviewBelowLeft();
  1240.     DView *emsg= NULL; //= this->InstallMessage(super);
  1241.     
  1242.     SetDlogItems( eto, efrom, eccopy, esubj, emsg);
  1243.     
  1244.     AddOkayCancelButtons(cSEND,"Send");
  1245.     this->NextSubviewToRight();
  1246.     DButton* hb= new DButton( cHelpButton, this, "Help");
  1247.     hb->SetResize( DView::fixed, DView::moveinsuper);
  1248.     
  1249.     DWindow::Open();
  1250. }
  1251.  
  1252.  
  1253.  
  1254. // class DFHCRCblocks
  1255.  
  1256.  
  1257. char* DFHCRCblocks::kAddress = "blocks@howard.fhcrc.org";
  1258. char* DFHCRCblocks::kTitle = "BLOCKS Search at FHCRC";
  1259. #ifdef OS_DOS
  1260. char* DFHCRCblocks::kHelp     = "fhcrc-bl.hel";     
  1261. #else
  1262. char* DFHCRCblocks::kHelp     = "fhcrc-blocks.help";     
  1263. #endif                                                                     
  1264.             
  1265.                                                                                 
  1266. DFHCRCblocks::DFHCRCblocks( long id, DTaskMaster* itsSuperior, DSequence* theSeq) :
  1267.     DSendMailDialog(id, itsSuperior,    -5,  -5,  -50,  -20, kTitle)
  1268. {
  1269.     fSeq= (DSequence*) theSeq->Clone();
  1270. }
  1271.  
  1272. DFHCRCblocks::~DFHCRCblocks()
  1273. {
  1274.     delete fSeq;
  1275. }
  1276.  
  1277. char* DFHCRCblocks::BuildMessage()
  1278. {
  1279.     char        *msg = NULL;
  1280.     
  1281.             // want IOSTREAMS here !!!!!!!!!!!!!!!!!!!! not damn sprintf's
  1282.     DTempFile* qfile = new DTempFile();
  1283.  
  1284.     msg= fMsg->GetText();
  1285.     fSeq->SetBases( msg);
  1286.     MemFree(msg);
  1287.     fSeq->DoWrite( qfile, DSeqFile::kPearson); 
  1288.             
  1289.     ulong msgbytes;
  1290.     msg= qfile->ReadIntoMemory( msgbytes);
  1291.     delete qfile;
  1292.  
  1293.     return msg;
  1294. }
  1295.  
  1296.  
  1297. Boolean DFHCRCblocks::IsMyAction(DTaskMaster* action) 
  1298. {    
  1299.     switch(action->Id()) {
  1300.  
  1301.         case cHelpButton:
  1302.             gApplication->OpenHelp(kHelp);
  1303.             return true;            
  1304.          
  1305.         default:
  1306.             return DSendMailDialog::IsMyAction(action);    
  1307.         }
  1308. }
  1309.  
  1310.  
  1311.  
  1312. void DFHCRCblocks::Open()
  1313. {
  1314.     DView* super = this;
  1315.  
  1316.     char* shorthelp1 =
  1317. "As an aid to detection and verification of protein sequence homology, the BLOCKS e-mail"LINEEND
  1318. "searcher compares a protein or DNA sequence to the current database of protein blocks."LINEEND
  1319. "Blocks are short multiply aligned ungapped segments corresponding to the most highly"LINEEND
  1320. "conserved regions of proteins.";
  1321.     SETNOTEFONT();
  1322.     (void) new DNotePanel(0,super,shorthelp1, 25*Nlm_stdCharWidth,0,gNoteFont);
  1323.     super->NextSubviewBelowLeft();
  1324.  
  1325.     DView *eto  = this->InstallTo(super, kAddress);
  1326.     DView *efrom= this->InstallFrom(super);  // don't have to display this one
  1327.     DView *esubj= NULL; 
  1328.     DView *eccopy= NULL;
  1329.  
  1330.     (void) new DPrompt(0, super, "Your query sequence:");
  1331.     super->NextSubviewBelowLeft();
  1332.     DView *emsg= this->InstallMessage(super, fSeq->Bases());
  1333.     
  1334.     SetDlogItems( eto, efrom, eccopy, esubj, emsg);
  1335.     
  1336.     AddOkayCancelButtons(cSEND,"Send");
  1337.     this->NextSubviewToRight();
  1338.     DButton* hb= new DButton( cHelpButton, this, "Help");
  1339.     hb->SetResize( DView::fixed, DView::moveinsuper);
  1340.     
  1341.     DWindow::Open();
  1342. }
  1343.  
  1344.  
  1345.  
  1346.  
  1347.  
  1348.  
  1349.  
  1350.  
  1351.  
  1352. // class DUWFGeneID
  1353.  
  1354.  
  1355. char* DUWFGeneID::kAddress = "geneid@bir.cedb.uwf.edu";
  1356. char* DUWFGeneID::kTitle = "GeneID at U.W.Florida";
  1357. #ifdef OS_DOS
  1358. char* DUWFGeneID::kHelp     = "geneid.hel";     
  1359. #else
  1360. char* DUWFGeneID::kHelp     = "geneid.help";     
  1361. #endif                                                                     
  1362.             
  1363.                                                                                 
  1364. DUWFGeneID::DUWFGeneID( long id, DTaskMaster* itsSuperior, DSequence* theSeq) :
  1365.     DSendMailDialog(id, itsSuperior,    -5,  -5,  -50,  -20, kTitle),
  1366.     fSeq(NULL)
  1367. {
  1368.     fSeq= (DSequence*) theSeq->Clone();
  1369. }
  1370.  
  1371. DUWFGeneID::~DUWFGeneID()
  1372. {
  1373.     if (fSeq) delete fSeq;
  1374. }
  1375.  
  1376. char* DUWFGeneID::BuildMessage()
  1377. {
  1378.     char        buf[512], name[128], name2[128];
  1379.     char        *msg = NULL;
  1380.     
  1381.             // want IOSTREAMS here !!!!!!!!!!!!!!!!!!!! not damn sprintf's
  1382.     DTempFile* qfile = new DTempFile();
  1383.  
  1384.      sprintf( buf, "Genomic Sequence");    qfile->WriteLine(buf);
  1385.  
  1386.     if (fSmall->GetStatus()) { 
  1387.         sprintf( buf, " -small_output");    qfile->WriteLine(buf); 
  1388.         }
  1389.     if (!fExonBlast->GetStatus()) { 
  1390.         sprintf( buf, " -noexonblast");    qfile->WriteLine(buf); 
  1391.         }
  1392.     if (fGeneBlast->GetStatus()) { 
  1393.         sprintf( buf, " -geneblast");    qfile->WriteLine(buf); 
  1394.         }
  1395.     if (fNetGene->GetStatus()) { 
  1396.         sprintf( buf, " -netgene");    qfile->WriteLine(buf); 
  1397.         }
  1398.      
  1399.     fCodeX->GetTitle(name,128); 
  1400.     fCodeY->GetTitle(name2,128); 
  1401.     if (*name && *name2) {    
  1402.         sprintf( buf, " -known_coding %s %s",name,name2);    
  1403.         qfile->WriteLine(buf); 
  1404.         }
  1405.  
  1406.     fFirstX->GetTitle(name,128); 
  1407.     fFirstY->GetTitle(name2,128); 
  1408.     if (*name && *name2) {    
  1409.         sprintf( buf, " -first_exon %s %s",name,name2);    
  1410.         qfile->WriteLine(buf); 
  1411.         }
  1412.  
  1413.     fLastX->GetTitle(name,128); 
  1414.     fLastY->GetTitle(name2,128); 
  1415.     if (*name && *name2) {    
  1416.         sprintf( buf, " -last_exon %s %s",name,name2);    
  1417.         qfile->WriteLine(buf); 
  1418.         }
  1419.         
  1420.     fAltX->GetTitle(name,128); 
  1421.     fAltY->GetTitle(name2,128); 
  1422.     if (*name && *name2) {    
  1423.         sprintf( buf, " -alt_splicing %s %s",name,name2);    
  1424.         qfile->WriteLine(buf); 
  1425.         }
  1426.  
  1427.      sprintf( buf, "\n\n");    qfile->WriteLine(buf);
  1428.  
  1429.     msg= fMsg->GetText();
  1430.     fSeq->SetBases( msg);
  1431.     MemFree(msg);
  1432.     fSeq->DoWrite( qfile, DSeqFile::kPearson); 
  1433.             
  1434.     ulong msgbytes;
  1435.     msg= qfile->ReadIntoMemory( msgbytes);
  1436.     delete qfile;
  1437.  
  1438.     return msg;
  1439. }
  1440.  
  1441.  
  1442.  
  1443. Boolean DUWFGeneID::IsMyAction(DTaskMaster* action) 
  1444. {    
  1445.     switch(action->Id()) {
  1446.  
  1447.         case cHelpButton:
  1448.             gApplication->OpenHelp(kHelp);
  1449.             return true;            
  1450.          
  1451.         default:
  1452.             return DSendMailDialog::IsMyAction(action);    
  1453.         }
  1454. }
  1455.  
  1456.  
  1457.  
  1458. void DUWFGeneID::Open()
  1459. {
  1460.     DView* super = this;
  1461.     DCluster* clu;
  1462.  
  1463.     char *shorthelp1= 
  1464. "GeneID is an Artificial Intelligence system for analyzing vertebrate genomic DNA and"LINEEND
  1465. "prediction of exons and gene structure. You have the option of having NetGene splice"LINEEND
  1466. "site analysis also.  GeneID currently offers no analysis of cDNA or protein sequences.";
  1467.      
  1468.     SETNOTEFONT();
  1469.     (void) new DNotePanel(0,super,shorthelp1, 25*Nlm_stdCharWidth,0,gNoteFont);
  1470.     super->NextSubviewBelowLeft();
  1471.  
  1472.     DView *eto  = this->InstallTo(super, kAddress);
  1473.     DView *efrom= this->InstallFrom(super);  // don't have to display this one
  1474.     DView *esubj= NULL; 
  1475.     DView *eccopy= NULL;
  1476.  
  1477.     clu= new DCluster(0,super,0,0,false,"Options");
  1478.     super= clu;
  1479.  
  1480.     (void) new DPrompt(0, super, "NetGene analysis also");
  1481.     super->NextSubviewToRight();
  1482.     fNetGene= new DCheckBox(0,super,"");
  1483.     super->NextSubviewToRight();
  1484.     
  1485.     (void) new DPrompt(0, super, "Brief output");
  1486.     super->NextSubviewToRight();
  1487.     fSmall= new DCheckBox(0,super,"");
  1488.     super->NextSubviewBelowLeft();
  1489.  
  1490.     (void) new DPrompt(0, super, "Compare predicted gene model to aa databases w/ blast");
  1491.     super->NextSubviewToRight();
  1492.     fGeneBlast= new DCheckBox(0,super, "");
  1493.     super->NextSubviewBelowLeft();
  1494.  
  1495.     (void) new DPrompt(0, super, "Use exon blast (protein database search)");
  1496.     super->NextSubviewToRight();
  1497.     fExonBlast= new DCheckBox(0,super,"");
  1498.     fExonBlast->SetStatus(true);
  1499.     super->NextSubviewBelowLeft();
  1500.  
  1501.     (void) new DPrompt(0, super, "Region of known coding (start,end)");
  1502.     super->NextSubviewToRight();
  1503.     fCodeX= new DEditText(0,super,NULL,4);
  1504.     super->NextSubviewToRight();
  1505.     fCodeY= new DEditText(0,super,NULL,4);
  1506.     super->NextSubviewBelowLeft();
  1507.  
  1508.     (void) new DPrompt(0, super, "Coordinates of known first exon (start,end)");
  1509.     super->NextSubviewToRight();
  1510.     fFirstX= new DEditText(0,super,NULL,4);
  1511.     super->NextSubviewToRight();
  1512.     fFirstY= new DEditText(0,super,NULL,4);
  1513.     super->NextSubviewBelowLeft();
  1514.  
  1515.     (void) new DPrompt(0, super, "Coordinates of known last exon (start,end)");
  1516.     super->NextSubviewToRight();
  1517.     fLastX= new DEditText(0,super,NULL,4);
  1518.     super->NextSubviewToRight();
  1519.     fLastY= new DEditText(0,super,NULL,4);
  1520.     super->NextSubviewBelowLeft();
  1521.  
  1522.     (void) new DPrompt(0, super, "Region where splicing is blocked (start,end)");
  1523.     super->NextSubviewToRight();
  1524.     fAltX= new DEditText(0,super,NULL,4);
  1525.     super->NextSubviewToRight();
  1526.     fAltY= new DEditText(0,super,NULL,4);
  1527.     super->NextSubviewBelowLeft();
  1528.  
  1529.     super= this;
  1530.     
  1531.     (void) new DPrompt(0, super, "Your query sequence:");
  1532.     super->NextSubviewBelowLeft();
  1533.     DView *emsg= this->InstallMessage(super, fSeq->Bases());
  1534.     
  1535.     SetDlogItems( eto, efrom, eccopy, esubj, emsg);
  1536.     
  1537.     AddOkayCancelButtons(cSEND,"Send");
  1538.     this->NextSubviewToRight();
  1539.     DButton* hb= new DButton( cHelpButton, this, "Help");
  1540.     hb->SetResize( DView::fixed, DView::moveinsuper);
  1541.     
  1542.     DWindow::Open();
  1543. }
  1544.  
  1545.  
  1546.  
  1547.  
  1548.  
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554. // class DORNLGrail
  1555.  
  1556. // note: this method can handle multi-seq input -- fix later for fSeqList
  1557.  
  1558. char* DORNLGrail::kAddress = "GRAIL@ornl.gov";
  1559. char* DORNLGrail::kTitle = "Grail at ORNL";
  1560. #ifdef OS_DOS
  1561. char* DORNLGrail::kHelp     = "grail.hel";     
  1562. #else
  1563. char* DORNLGrail::kHelp     = "grail.help";     
  1564. #endif                                                                     
  1565.             
  1566.                                                                                 
  1567. DORNLGrail::DORNLGrail( long id, DTaskMaster* itsSuperior, DSequence* theSeq) :
  1568.     DSendMailDialog(id, itsSuperior,    -5,  -5,  -50,  -20, kTitle),
  1569.     fSeq(NULL)
  1570. {
  1571.     fSeq= (DSequence*) theSeq->Clone();
  1572. }
  1573.  
  1574. DORNLGrail::~DORNLGrail()
  1575. {
  1576.     if (fSeq) delete fSeq;
  1577. }
  1578.  
  1579. char* DORNLGrail::BuildMessage()
  1580. {
  1581.     char        buf[512];
  1582.     char        *msg = NULL;
  1583.     
  1584.             // want IOSTREAMS here !!!!!!!!!!!!!!!!!!!! not damn sprintf's
  1585.     DTempFile* qfile = new DTempFile();
  1586.  
  1587.     short nseq= 1; // fix later for SeqList input
  1588.      sprintf( buf, "Sequences %d", nseq);    qfile->WriteLine(buf);
  1589.  
  1590.     if (fGrail2->GetStatus()) { 
  1591.         sprintf( buf, " -2");    qfile->WriteLine(buf); 
  1592.         }
  1593.     if (fExon->GetStatus()) { 
  1594.         sprintf( buf, " -E");    qfile->WriteLine(buf); 
  1595.         }
  1596.  
  1597.      sprintf( buf, "\n");    qfile->WriteLine(buf);
  1598.  
  1599.     msg= fMsg->GetText();
  1600.     fSeq->SetBases( msg);
  1601.     MemFree(msg);
  1602.     fSeq->DoWrite( qfile, DSeqFile::kPearson); 
  1603.             
  1604.     ulong msgbytes;
  1605.     msg= qfile->ReadIntoMemory( msgbytes);
  1606.     delete qfile;
  1607.  
  1608.     return msg;
  1609. }
  1610.  
  1611.  
  1612.  
  1613. Boolean DORNLGrail::IsMyAction(DTaskMaster* action) 
  1614. {    
  1615.     switch(action->Id()) {
  1616.  
  1617.         case cHelpButton:
  1618.             gApplication->OpenHelp(kHelp);
  1619.             return true;            
  1620.          
  1621.         default:
  1622.             return DSendMailDialog::IsMyAction(action);    
  1623.         }
  1624. }
  1625.  
  1626.  
  1627.  
  1628. void DORNLGrail::Open()
  1629. {
  1630.     DView* super = this;
  1631.     DCluster* clu;
  1632.  
  1633.     char *shorthelp1= 
  1634. "GRAIL provides analysis of protein coding potential of a DNA sequence, and an option"LINEEND
  1635. "for protein sequence database search of putative coding regions.  The coding"LINEEND
  1636. "recognition portion of the system uses a neural network which combines a series of"LINEEND
  1637. "coding prediction algorithms.";
  1638.      
  1639.     SETNOTEFONT();
  1640.     (void) new DNotePanel(0,super,shorthelp1, 25*Nlm_stdCharWidth,0,gNoteFont);
  1641.     super->NextSubviewBelowLeft();
  1642.  
  1643.     DView *eto  = this->InstallTo(super, kAddress);
  1644.     DView *efrom= this->InstallFrom(super);  // don't have to display this one
  1645.     DView *esubj= NULL; 
  1646.     DView *eccopy= NULL;
  1647.  
  1648.     clu= new DCluster(0,super,0,0,false,"Options");
  1649.     super= clu;
  1650.  
  1651.     (void) new DPrompt(0, super, "Use Grail version 2");
  1652.     super->NextSubviewToRight();
  1653.     fGrail2= new DCheckBox(0,super, "");
  1654.     super->NextSubviewBelowLeft();
  1655.  
  1656.     (void) new DPrompt(0, super, "Compare found exon to protein database");
  1657.     super->NextSubviewToRight();
  1658.     fExon= new DCheckBox(0,super, "");
  1659.     super->NextSubviewBelowLeft();
  1660.  
  1661.     super= this;
  1662.     
  1663.     (void) new DPrompt(0, super, "Your query sequence:");
  1664.     super->NextSubviewBelowLeft();
  1665.     DView *emsg= this->InstallMessage(super, fSeq->Bases());
  1666.     
  1667.     SetDlogItems( eto, efrom, eccopy, esubj, emsg);
  1668.     
  1669.     AddOkayCancelButtons(cSEND,"Send");
  1670.     this->NextSubviewToRight();
  1671.     DButton* hb= new DButton( cHelpButton, this, "Help");
  1672.     hb->SetResize( DView::fixed, DView::moveinsuper);
  1673.     
  1674.     DWindow::Open();
  1675. }
  1676.  
  1677.